package practice;

/**
 * @Description: https://leetcode.cn/problems/reverse-integer/
 * @Author Ammar
 * @Create 2023/7/21 21:18
 */
public class _7_整数反转 {
    public int reverse(int x) {
        int res = 0;
        while (x != 0) {
            int yushu = x % 10;
            int next = res * 10 + yushu;
            if (res != (next - yushu) / 10) return 0;
            res = next;
            x /= 10;
        }
        return res;
    }
}
